package 开始的剑指offer8月.面经常用算法题09开始的;

import java.util.Arrays;

// https://leetcode-cn.com/problems/delete-node-in-a-linked-list/
public class 链表237删除链表中的节点0902 {

     static  class ListNode {
         int val;
         ListNode next;
         ListNode(int x) { val = x; }
     }



    public static  void deleteNode(ListNode node) {
            node.val = node.next.val;
            node.next = node.next.next;
        }
        public static void print(ListNode head){
            while (head!=null){
                System.out.print(head.val+" ");
                head=head.next;
            }
        }

    public static void main(String[] args) {
         //[4,5,1,9]
        //5
        ListNode node=new ListNode(4);
        ListNode node1=new ListNode(5);
        ListNode node2=new ListNode(1);
        ListNode node3=new ListNode(9);
        node.next=node1;
        node1.next=node2;
        node2.next=node3;
        node3.next=null;
        print(node);
        deleteNode(node1);
        System.out.println();
        print(node);

    }
}
